<template>
    <el-container style="height: 100%;">
        <el-header>
            <el-row :gutter="20" style="color:#000">
                <el-col :span="12">
                    <div style="font-size: 20px; font-weight: 900;line-height: 60px">
                        美易通--2018
                    </div>
                </el-col>
                <el-col :span="12">
                    <div style="float: right;display: flex;align-items: center;height: 60px">
                        <headImg :imgUrl="admin.headimg" size="50"></headImg>
                        <el-dropdown>
                            <span style="margin-left:10px; cursor: pointer">
                        {{admin.name}}<i class="el-icon-arrow-down el-icon--right"></i>
                      </span>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item @click.native="editAdmin">个人信息</el-dropdown-item>
                                <el-dropdown-item @click.native="changePassword">更改密码</el-dropdown-item>
                                <el-dropdown-item @click.native="quit">注销</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </el-col>
            </el-row>
        </el-header>
        <el-container>
            <el-aside width="200px" style="background-color: rgb(84, 92, 100)">
                <el-menu router background-color="#545c64" text-color="#fff">
                    <el-submenu index="11">
                        <template slot="title"><i class="el-icon-menu"></i>首页</template>
                        <el-menu-item index="/">数据分析</el-menu-item>
                    </el-submenu>
                    <el-submenu index="1">
                        <template slot="title"><i class="el-icon-h-bumen"></i>基础管理</template>
                        <el-menu-item index="/bumenList">部门列表</el-menu-item>
                        <el-menu-item index="/userList">员工列表</el-menu-item>
                    </el-submenu>
                    <el-submenu index="2">
                        <template slot="title"><i class="el-icon-h-guke1"></i>客户管理</template>
                        <el-menu-item index="/guestList">客户列表</el-menu-item>
                    </el-submenu>
                    <!-- <el-submenu index="12">
                        <template slot="title"><i class="el-icon-menu"></i>品牌厂商</template>
                        <el-menu-item index="/factoryList">厂商管理</el-menu-item>
                        <el-menu-item index="/brandList">品牌管理</el-menu-item>
                    </el-submenu> -->
                    <el-submenu index="3">
                        <template slot="title"><i class="el-icon-h-wendang"></i>品项管理</template>
                        <el-menu-item index="/subjectList">项目列表</el-menu-item>
                        <el-menu-item index="/goodsList">产品列表</el-menu-item>
                        <el-menu-item index="/shopGoodsList">自营商品</el-menu-item>
                    </el-submenu>
                    <el-submenu index="4">
                        <template slot="title"><i class="el-icon-h-vipcard"></i>卡项管理</template>
                        <el-menu-item index="/cardList">卡项列表</el-menu-item>
                    </el-submenu>
                    <el-submenu index="5">
                        <template slot="title"><i class="el-icon-h-kaidan"></i>经营管理</template>
                        <el-menu-item index="/openCardList">开卡列表</el-menu-item>
                        <el-menu-item index="/orderList">开单列表</el-menu-item>
                        <el-menu-item index="/rechargeList">充值列表</el-menu-item>
                        <el-menu-item index="/debtList">欠款列表</el-menu-item>
                        <el-menu-item index="/backCardList">退卡退款</el-menu-item>
                    </el-submenu>
                    <el-submenu index="6">
                        <template slot="title"><i class="el-icon-h-yue3"></i>财务管理</template>
                        <el-menu-item index="/accountList">收款帐号</el-menu-item>
                        <el-menu-item index="/checkList">提成分配</el-menu-item>
                        <el-menu-item index="/backCheckList">提成扣除</el-menu-item>
                        <el-menu-item index="/userPayList">员工工资</el-menu-item>
                        <el-menu-item index="/costList">费用收支</el-menu-item>
                    </el-submenu>
                    <el-submenu index="7">
                        <template slot="title"><i class="el-icon-h-yue"></i>资金信息</template>
                        <el-menu-item index="/moneyList">资金流量</el-menu-item>
                        <el-menu-item index="/featList">部门业绩</el-menu-item>
                        <el-menu-item index="/otherShopFeat">跨店消费</el-menu-item>
                    </el-submenu>
                    <el-submenu index="8">
                        <template slot="title"><i class="el-icon-h-liushi1"></i>库存管理</template>
                        <el-menu-item index="/stockList">库存列表</el-menu-item>
                        <el-menu-item index="/pickList">领料记录</el-menu-item>
                        <el-menu-item index="/stockLog">库存记录</el-menu-item>
                    </el-submenu>
                    <el-submenu index="9">
                        <template slot="title"><i class="el-icon-h-chakan"></i>权限管理</template>
                        <el-menu-item index="/permissionLevel">权限等级</el-menu-item>
                        <el-menu-item index="/adminRule">账号权限</el-menu-item>
                    </el-submenu>
                    <el-submenu index="10">
                        <template slot="title"><i class="el-icon-h-set2"></i>基础设置</template>
                        <el-menu-item index="#" @click="openSetting">基础设置</el-menu-item>
                        <el-menu-item index="/erWeiMa">客户二维码</el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main style="background-color: #F0F3F3">
                <transition name="fade" mode="out-in">
                    <router-view></router-view>
                </transition>
            </el-main>
        </el-container>
    </el-container>
</template>
<script>
import C from '#/src/common/common.js'
import Setting from '#/src/shop/setting.js'
import headImg from '@/components/headImg.vue'
// import { ipcRenderer, remote } from 'electron'
export default {
    name: 'app',
    data() {
        return {
            admin: { headimg: '' }
        }
    },
    methods: {
        openSetting() {
            Setting.openSetting()
        },
        async getAdminInfo() {
            let data = await C.ajax('/shop/index/getadmininfo', {}, 'post')
            this.admin = data.ainfo
            C.setLocalStorage('initConfig', JSON.stringify(data.initConfig))
        },
        async editAdmin() {
            await C.openBrowserWindow('/editAdmin', {}, {
                transparent: true,
                frame: false,
                // openDevTools: true,
                width: 390,
                height: 600,
                useSpa: true,
                spaModel: 'shop'
            })
        },
        async changePassword(row) {
            let res = await C.openBrowserWindow('/changePassword', row, {
                transparent: true,
                frame: false,
                // openDevTools: true,
                width: 390,
                height: 300,
                useSpa: true,
                spaModel: 'shop'
            })
            if (res) {
                C.success(res.data.info)
            }
        },
        quit () {
            C.confirm('确定要退出吗？', async () => {
                await C.ajax('/login/public/logout', {}, 'post')
                C.setLocalStorage('permission')
                C.setLocalStorage('initConfig')
                C.setLocalStorage('usertoken')
                // 打开登录关闭本窗口aaaaaa
                C.openBrowserWindow('/', {}, {
                    width: 393,
                    height: 500,
                    resizable: false,
                    transparent: true,
                    frame: false,
                    useSpa: true,
                    spaModel: 'login'
                })
                C.closewin()
            })
        }
    },
    mounted: function() {
        this.getAdminInfo()
        // ipcRenderer.send('_changeMainWindow', remote.getCurrentWindow().id)
    },
    components: { headImg }
}
</script>
<style>

</style>